package com.news.news.web;

import com.github.pagehelper.PageInfo;
import com.news.news.modle.Admin;
import com.news.news.modle.User;
import com.news.news.service.UsersService;
import com.news.news.util.CommonResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(path = "/admin/UsersCtl")
public class UsersController {
    @Resource
    UsersService usersService;
    @RequestMapping(value = "/list")
    public CommonResult list(@RequestBody User user) {
//        System.out.println(admin);
        PageInfo<User> userPageInfo = usersService.usersList(user);
        CommonResult commonResult = new CommonResult(200, userPageInfo, "成功");

        return commonResult;
    }
//
    /*改变用户State*/
    @RequestMapping(value = "/changeState")
    public CommonResult changeState(@RequestBody User user) {
//        System.out.println(admin);
        usersService.changeState(user);
        return new CommonResult(200,null, "成功");
    }

    @RequestMapping(value = "/deleteUser")
    public CommonResult deleteUser(Integer id) {
//        System.out.println(admin);
        usersService.deleteUser(id);
        return new CommonResult(200,null, "成功");
    }
}
